<?php

Raise::load('core.text.format.IRaiseFormatter');
Raise::load('core.helper.RaiseHelper');

class RaiseDateTimeFormatter extends RaiseHelper implements IRaiseFormatter {
    
    const ATOM = 'Y-m-d\TH:i:sP';
    const COOKIE = 'l, d-M-y H:i:s T' ;
    const ISO8601 = 'Y-m-d\TH:i:sO' ;
    const RFC822 = 'D, d M y H:i:s O' ;
    const RFC850 = 'l, d-M-y H:i:s T' ;
    const RFC1036 = 'D, d M y H:i:s O' ;
    const RFC1123 = 'D, d M Y H:i:s O' ;
    const RFC2822 = 'D, d M Y H:i:s O' ;
    const RFC3339 = 'Y-m-d\TH:i:sP' ;
    const RSS = 'D, d M Y H:i:s O' ;
    const W3C = 'Y-m-d\TH:i:sP';
    
    private $format;
    
    public function __construct($format){
        $this->format = $format;
    }
    
    public function format(){
        return $this->format;
    }
    
    public function parse($date) {
        if($date instanceof RaiseDateTime){
            $date = $date->toTimestamp();
        }
        return gmdate($this->format, $date);
    }
    
}